function [  ] = KFold( allCarsMatrix )
%UNTITLED2 Summary of this function goes here
%   Detailed explanation goes here
load('selected_obj.mat');

testingMatrix = [];
traingingMatrix = [];
lable =[];
class_label = [];
total_guess = [];
predection = [];
allAttr={};
types={};
for i=1:127
   allAttr = [allAttr {strcat('hog',num2str(i))}];
   types = [types {'numeric'}];
end
for i=1:127
   allAttr = [allAttr {strcat('wavlet',num2str(i))}];
   types = [types {'numeric'}];
end
      
   allAttr = [allAttr {'class'}];
   types = [types {'f s b'}];
   
c = 1;
while(c < 11)
    if(c==1)
       testing = allCarsMatrix(1:100,3:257);
       label = horzcat(lable, allCarsMatrix(1:100,257));
       training = allCarsMatrix(101:999,3:257);
      
       
    else
       testing = allCarsMatrix((c-1)*100+1:(c)*100,3:257);
       label = horzcat(lable, allCarsMatrix((c-1)*100+1:(c)*100,257));
       training = allCarsMatrix(1:(c-1)*100,3:257);
       training = vertcat(training,(allCarsMatrix((c*100)+1:999,3:257)));
       %training2 =allCarsMatrix((c*100)+1:1008,3:257);
    end
     
     %label = label';
     class_label = [class_label label];
     label= [];
     trainingfile = strcat('training_a', num2str(c),'.arff');
     testingfile = strcat('testing_a' , num2str(c),'.arff');
     %create and save training data set
     wekaobj = matlab2weka('training',allAttr,training);
     saveARFF(trainingfile,wekaobj);
     %create and save testing data set
     wekaobj2 = matlab2weka('testing',allAttr,testing);
     saveARFF(testingfile,wekaobj2);
     c=c+1;
     disp('I am here!')
end
     %load arff file.
     for k=1:10
        training = loadARFF(strcat('training_a',num2str(k),'-fixed.arff'));
        testing = loadARFF(strcat('testing_a',num2str(k),'-fixed.arff'));
        model = trainWekaClassifier(training,'functions.SMO','-C 1.0 -L 0.001 -P 1.0E-12 -N 0 -V -1 -W 1 -K "weka.classifiers.functions.supportVector.PolyKernel -C 250007 -E 1.0"');
        [predictedClass, classProbs] = wekaClassify(testing,model);
        predection  = horzcat(predection, predictedClass);
        correct_guess = 0;
        for i=1:100
            if(class_label(i,1) ==  -((predection(i,1))+10))
                 correct_guess = correct_guess+1;
            end
        end
        total_guess = horzcat(total_guess,correct_guess);
        correct_guess = 0;
        disp('testingMatrix')
     end
     
    display(correct_guess)

disp('testingMatrix')
%testingMatrix =  allCarsMatrix;
    
end

